﻿Imports Entidades
Public Class frmBorrarFamilia
    Private lista As New List(Of Familia)
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Me.Close()

    End Sub

    Private Sub frmBorrarFamilia_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        lista = miGestion.obtenerFamilias
        For i As Integer = 0 To lista.Count - 1
            cboFamilias.Items.Add(lista(i).Nombre)
        Next
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If cboFamilias.Text = "" Then
            MessageBox.Show("Selecciona una familia")
            Exit Sub
        End If
        Dim st As String = miGestion.BorrarFamilia(lista(cboFamilias.SelectedIndex))
        If st <> "" Then
            MessageBox.Show(st)
            Exit Sub
        End If
        MessageBox.Show("Familia eliminada correctamente")
        cboFamilias.Items.Clear()
        lista = miGestion.obtenerFamilias
        For i As Integer = 0 To lista.Count - 1
            cboFamilias.Items.Add(lista(i).Nombre)
        Next
    End Sub

End Class